/*
 * Tangram
 * Copyright 2009 Baidu Inc. All rights reserved.
 *
 * path: ui/dialog/Slider$progressBar.js
 * author: berg
 * version: 1.0.0
 * date: 2010-05-18
 */


///import baidu.ui.slider.Slider;

///import baidu.ui.progressBar.ProgressBar;

///import baidu.dom.insertHTML;

///import baidu.string.format;


/**
 * addon
 *
 * 和进度条结合
 * 滑块不能超过进度条的进度
 */

baidu.ui.slider.Slider.prototype.tplProgressContainer = "<div id='#{progressbarId}' class='#{progressbarClass}' style='position:absolute; left:0px; top:0px;'></div>";
baidu.ui.slider.Slider.register(function(slider){
    slider.addEventListener("onload", function(){
        var me = this;
        baidu.dom.insertHTML(
            me.getBody(),
            "afterBegin",
            baidu.string.format(me.tplProgressContainer,{
                progressbarId : me.getId("progressbar"),
                progressbarClass : me.getClass("progressbar")
            })
        );

        me.progressBar = new baidu.ui.progressBar.ProgressBar({
			layout:me.layout,
            value : 10,
            skin : me.skin ? me.skin + "-loaderProgressbar" : null,
            //限制slider范围
            onupdate : function(){
                me.range = [0, me.progressBar.getValue()];
                me.update();
            }
        });
        me.progressBar.render(me.getId("progressbar"));
    });
});
